/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.cs.mailbox.MailItem.Type;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.MailboxOperation;
/*    */ import com.zimbra.cs.redolog.RedoLogInput;
/*    */ import com.zimbra.cs.redolog.RedoLogOutput;
/*    */ import com.zimbra.cs.redolog.Version;
/*    */ import java.io.IOException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class RenameItem
/*    */   extends RedoableOp
/*    */ {
/*    */   protected int mId;
/*    */   protected MailItem.Type type;
/*    */   protected int mFolderId;
/*    */   protected String mName;
/*    */   protected Long mDate;
/*    */   
/*    */   public RenameItem()
/*    */   {
/* 40 */     super(MailboxOperation.RenameItem);
/* 41 */     this.mId = (this.mFolderId = 0);
/* 42 */     this.type = MailItem.Type.UNKNOWN;
/*    */   }
/*    */   
/*    */   public RenameItem(int mailboxId, int id, MailItem.Type type, String name, int folderId) {
/* 46 */     this(mailboxId, id, type, name, folderId, null);
/*    */   }
/*    */   
/*    */   public RenameItem(int mailboxId, int id, MailItem.Type type, String name, int folderId, Long date) {
/* 50 */     this();
/* 51 */     setMailboxId(mailboxId);
/* 52 */     this.mId = id;
/* 53 */     this.type = type;
/* 54 */     this.mFolderId = folderId;
/* 55 */     this.mName = (name != null ? name : "");
/* 56 */     this.mDate = date;
/*    */   }
/*    */   
/*    */   protected String getPrintableData()
/*    */   {
/* 61 */     return "id=" + this.mId + ", type=" + this.type + ", name=" + this.mName + ",parent=" + this.mFolderId + ", date=" + this.mDate;
/*    */   }
/*    */   
/*    */   protected void serializeData(RedoLogOutput out) throws IOException
/*    */   {
/* 66 */     out.writeInt(this.mId);
/* 67 */     out.writeInt(this.mFolderId);
/* 68 */     out.writeUTF(this.mName);
/* 69 */     out.writeByte(this.type.toByte());
/*    */     
/*    */ 
/* 72 */     out.writeBoolean(this.mDate != null);
/* 73 */     if (this.mDate != null) {
/* 74 */       out.writeLong(this.mDate.longValue());
/*    */     }
/*    */   }
/*    */   
/*    */   protected void deserializeData(RedoLogInput in) throws IOException
/*    */   {
/* 80 */     this.mId = in.readInt();
/* 81 */     this.mFolderId = in.readInt();
/* 82 */     this.mName = in.readUTF();
/* 83 */     this.type = MailItem.Type.of(in.readByte());
/* 84 */     if ((getVersion().atLeast(1, 40)) && 
/* 85 */       (in.readBoolean())) {
/* 86 */       this.mDate = Long.valueOf(in.readLong());
/*    */     }
/*    */   }
/*    */   
/*    */   public void redo()
/*    */     throws Exception
/*    */   {
/* 93 */     Mailbox mailbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
/* 94 */     mailbox.rename(getOperationContext(), this.mId, this.type, this.mName, this.mFolderId, this.mDate);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/RenameItem.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */